#include "CharacterManager.h"


Player* CharacterManager::CreatePlayer(Handle camera, float speed, Color clr)
{
	if (!mPlayer)
	{
		Player *player = new Player(camera, speed, clr);
		mPlayer = player;
		mCharacters.push_back(mPlayer);
	}
	return mPlayer;
}

Bot* CharacterManager::CreateBot()
{
	Bot* bot = new Bot();
	mBots.push_back(bot);
	mCharacters.push_back(bot);
	return bot;
}

Character* CharacterManager::FindCharacter( Handle mesh )
{
	for (size_t i = 0; i < mCharacters.size(); ++i)
	{
		if (mesh == mCharacters[i]->GetMesh())
		{
			return mCharacters[i];
		}
	}
	return 0;
}

CharacterManager::CharacterManager()
	:mPlayer(0)
{

}

CharacterManager::~CharacterManager()
{
	for (size_t i = 0; i < mCharacters.size(); ++i)
	{
		delete mCharacters[i];
	}
}

AngryBot * CharacterManager::CreateAngryBot()
{
	AngryBot* aBot = new AngryBot(Vec3D(20,0,25), mPlayer, 20);
	mBots.push_back(aBot);
	mCharacters.push_back(aBot);
	return aBot;
}


